#!/usr/bin/python
#
# Copyright (c) 2009 Julius Volz
# See LICENSE for details.

import datetime

def raw(value):
  return value

def string(value):
  if type(value) == str:
    return value
  return value['value']

def integer(value):
  if type(value) == str:
    return int(value)
  return int(value['value'])

def decimal(value):
  if type(value) == str:
    return float(value)
  return float(value['value'])

def date(value):
  if type(value) == str:
    date_str = value
  else:
    date_str = value['value']

  year, month, day = [int(part) for part in date_str.split('-')]
  return datetime.date(year, month, day)
